import React from 'react'
import { Switch, Route, Redirect } from "react-router-dom"
import BeforeEach from './BeforeEach';
export default function RouterView(props) {
    const { routerList } = props;
    return (
        <Switch>
            {routerList.length > 0 && routerList.map(v => {
                return v.path ? <Route key={v.path} path={v.path} render={(props) => <BeforeEach {...props} {...v} />} /> : <Redirect from={v.from} to={v.to} key={v.from + v.to} />
            })}
        </Switch>
    )
}
